from datetime import datetime, time

# 彩票类型配置
LOTTERY_TYPES = {
    'ssq': {
        'name': '双色球',
        'draw_days': [1, 3, 6],  # 周二、周四、周日
        'draw_time': time(21, 15),  # 开奖时间
        'data_file': 'data/lottery_draws.csv',
        'url': 'https://m.17500.cn/kj-m/list-ssq.html',
        'backup_url': 'https://m.17500.cn/lottery-m/ssq.html'  # 备用数据源
    },
    '3d': {
        'name': '福彩3D',
        'draw_days': [0, 1, 2, 3, 4, 5, 6],  # 每天开奖
        'draw_time': time(21, 15),
        'data_file': 'data/3d_draws.csv',
        'url': 'https://m.17500.cn/kj-m/list-3d.html'
    },
    'kl8': {
        'name': '快乐8',
        'draw_days': [0, 1, 2, 3, 4, 5, 6],
        'draw_time': time(21, 30),
        'data_file': 'data/kl8_draws.csv',
        'url': 'https://m.17500.cn/kj-m/list-kl8.html'
    },
    '7lc': {
        'name': '七乐彩',
        'draw_days': [0, 2, 4],  # 周一、周三、周五
        'draw_time': time(21, 15),
        'data_file': 'data/7lc_draws.csv',
        'url': 'https://m.17500.cn/kj-m/list-7lc.html'
    },
    'pl3': {
        'name': '排列3',
        'draw_days': [0, 1, 2, 3, 4, 5, 6],
        'draw_time': time(21, 25),
        'data_file': 'data/pl3_draws.csv',
        'url': 'https://m.17500.cn/kj-m/list-pl3.html'
    },
    'dlt': {
        'name': '大乐透',
        'draw_days': [0, 2, 5],  # 周一、三、六
        'draw_time': time(21, 25),
        'data_file': 'data/dlt_draws.csv',
        'url': 'https://m.17500.cn/kj-m/list-dlt.html'
    },
    'pl5': {
        'name': '排列5',
        'draw_days': [0, 1, 2, 3, 4, 5, 6],
        'draw_time': time(21, 25),
        'data_file': 'data/pl5_draws.csv',
        'url': 'https://m.17500.cn/kj-m/list-pl5.html'
    },
    '7xc': {
        'name': '七星彩',
        'draw_days': [1, 4, 6],  # 周二、周五、周日
        'draw_time': time(21, 25),
        'data_file': 'data/7xc_draws.csv',
        'url': 'https://m.17500.cn/kj-m/list-7xc.html'
    }
}

# 数据目录配置
DATA_DIR = 'data'

# 爬虫配置
CRAWLER_CONFIG = {
    'max_retries': 3,
    'retry_delay': 5,
    'timeout': 10,
    'backup_retry_delay': 10,  # 主爬虫失败后等待多少秒再尝试备用爬虫
    'backup_max_retries': 2,   # 备用爬虫最大重试次数
    'headers': {
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
        "Referer": "https://m.17500.cn/kj-m/list-ssq.html",
        "Origin": "https://m.17500.cn",
        "Host": "m.17500.cn",
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate, br, zstd",
        "Accept-Language": "zh-CN,zh;q=0.9",
        "Cache-Control": "no-cache",
        "Connection": "keep-alive",
        "Content-Type": "application/x-www-form-urlencoded",
        "Pragma": "no-cache",
        "Sec-Ch-Ua": '"Chromium";v="134", "Not:A-Brand";v="24", "Google Chrome";v="134"',
        "Sec-Ch-Ua-Mobile": "?0",
        "Sec-Ch-Ua-Platform": '"macOS"',
        "Sec-Fetch-Dest": "empty",
        "Sec-Fetch-Mode": "cors",
        "Sec-Fetch-Site": "same-origin"
    }
}

# 日志配置
LOG_CONFIG = {
    'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    'datefmt': '%Y-%m-%d %H:%M:%S'
} 